package com.bangbang.controller;


import com.bangbang.configresult.Result;
import com.bangbang.configresult.ResultEnum;
import com.bangbang.pojo.TbSeckillCourse;
import com.bangbang.service.ITbSeckillCourseService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 秒杀课程商品信息表 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2021-08-12
 */
@RestController
@RequestMapping("/bangbang/tbSeckillCourse")
public class TbSeckillCourseController {

    @Autowired
    private ITbSeckillCourseService tbSeckillCourseService;

    @GetMapping
    @ApiOperation("秒杀课程查询")
    public Result selectAll(){
        List<TbSeckillCourse> seckillCourseList = tbSeckillCourseService.selectAll();
        return Result.buildResult(ResultEnum.SUCCESS).setResult(seckillCourseList);
    }

//    秒杀抢购  (增加)
    @PostMapping
    @ApiOperation("秒杀的抢购 && 秒杀的订单的增加")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid",value = "用户ID",required = true,paramType = "query"),
            @ApiImplicitParam(name = "secId",value = "秒杀商品的ID",required = true,paramType = "query")
    })
    public Result insertSnapped(@RequestParam("uid")Long uid,@RequestParam("secId")Long secId) throws Exception {
            tbSeckillCourseService.insertSnapped(uid,secId);
        return Result.buildResult(ResultEnum.SUCCESS);
    }
}

